<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        #container {
            width: 90%;
            max-width: 1000px;
            margin: 0 auto;
            background-color: #eeeeee;
            padding: 20px;
        }

        form {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            margin-top: 20px;
        }

        label, input {
            margin-bottom: 10px;
            font-size: 24px;
        }

        label {
            width: 120px;
            text-align: right;
            margin-right: 20px;
        }

        input[type="submit"] {
            width: 100%;
            height: 60px;
            line-height: 60px;
            text-align: center;
            text-decoration: none;
            color: white;
            background-color: #00adb5;
            border-radius: 10px;
            margin-top: 20px;
        }

        input[type="submit"]:hover {
            background-color: #3f72af;
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        function updatePassword() {
            // 使用jQuery的ajax方法发送POST请求
            $.ajax({
                url: "http://localhost:8080/stadium/common/modifyPassword",
                type: "GET",
                data: $("#update-form").serialize(),
                dataType: "json",
                success: function (data) {
                    console.log(data);
                    alert("修改密码成功");
                    window.location.href = "http://localhost:8080/stadium/reservation_page/IndividualCenter.html";
                },
                error: function (xhr) {
                    alert("修改密码失败：" + xhr.status);
                }
            });
        }

        $(document).ready(function () {
            $("#update-form").on("submit", function (event) {
                event.preventDefault();
                updatePassword();
            });
        });
    </script>
</head>
<body>
<div id="container">
    <form id="update-form">
        <label for="old-password">旧密码：</label>
        <input type="password" id="old-password" name="oldPassword" required>

        <label for="new-password">新密码：</label>
        <input type="password" id="new-password" name="newPassword" required>

        <input type="submit" value="确认修改">
    </form>
</div>
</body>
</html>